﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QuanLyKhachHang
{
    public partial class fThongTin : Form
    {
        string MaKhachHang, NguoiDungHienTai;
        public fThongTin()
        {
            InitializeComponent();
        }
        public fThongTin(string MaKhachHang,string NguoiDungHienTai)
        {
            InitializeComponent();
            BtxtMaKhachHang.Text = CtxtMaKhachHang.Text = DtxtMaKhachHang.Text = this.MaKhachHang = MaKhachHang;

            this.NguoiDungHienTai = NguoiDungHienTai;

        }
        #region Thông tin chung
        void LoadThongTinChung()
        {	
            DataTable table = Data.NVKhachHang.ChonTatCa(MaKhachHang);
	        DataRow row = table.Rows[0];
            AtxtNhomKhachHang.Text = row["TenNhomKhachHang"].ToString();
            AtxtTenCongTy.Text = row["TenCongTy"].ToString();
            AtxtLinhVuc.Text = row["LinhVuc"].ToString();
            AtxtDiaChi.Text = row["DiaChi"].ToString();
            AtxtDienThoai.Text = row["DienThoai"].ToString();
            AtxtNgayLienHe.Text = row["NgayLienHe"].ToString();
            AtxtDanhGiaNhuCau.Text = row["DanhGia"].ToString();
            AtxtGhiChu.Text = row["GhiChu"].ToString();
        }        
        #endregion

        #region Thông tin liên lạc
        bool BKiemTraThongTinNhap()
        {
            if (string.IsNullOrEmpty(BtxtMaKhachHang.Text.ToString()) || (string.IsNullOrEmpty(BtxtNguoiLienHe.Text.ToString())) || (string.IsNullOrEmpty(BcbChucVu.Text.ToString())))
            {
                MessageBox.Show("Bạn vui lòng kiểm tra lại thông tin nhập.","Loi nhap du lieu",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return false;
            }
            else
            {
                return true;
            }
        }
        void BDieuKhien()
        {
            BbtnSua.Enabled = BbtnXoa.Enabled = (BdgvDanhSach.RowCount != 0);
        }
        BindingSource Bbds = new BindingSource();
        void BLoadDuLieu()
        {
            Bbds.DataSource = Data.NVChiTiet.ChonTatCa(BtxtMaKhachHang.Text.Trim());
            BdgvDanhSach.DataSource = Bbds;
            BDieuKhien();

        }

        private void BbtnThem_Click(object sender, EventArgs e)
        {
            if (BKiemTraThongTinNhap() == false)
            {
                return;
            }
            Data.TTChiTiet ChiTiet = new Data.TTChiTiet();
            ChiTiet.MaChiTiet = SinhMa.Sinh("CT", Data.NVChiTiet.ChonTatCa(), "0000000000");
            ChiTiet.MaKhachHang = BtxtMaKhachHang.Text.Trim();
            ChiTiet.NguoiLienHe = BtxtNguoiLienHe.Text.Trim();
            ChiTiet.ChucVu = BcbChucVu.SelectedItem.ToString();
            ChiTiet.DiaChi = BtxtDiaChi.Text.Trim();
            ChiTiet.DienThoai = BtxtDienThoai.Text.Trim();
            ChiTiet.DiDong = BtxtDiDong.Text.Trim();
            ChiTiet.Email = BtxtEmail.Text.Trim();
            Data.NVChiTiet.Them(ChiTiet);
            BLoadDuLieu();
        }

        private void BbtnSua_Click(object sender, EventArgs e)
        {
            if (BKiemTraThongTinNhap() == false)
            {
                return;
            }
            Data.TTChiTiet ChiTiet = new Data.TTChiTiet();
            ChiTiet.MaChiTiet = BtxtMaChiTiet.Text.Trim();
            ChiTiet.MaKhachHang = BtxtMaKhachHang.Text.Trim();
            ChiTiet.NguoiLienHe = BtxtNguoiLienHe.Text.Trim();
            ChiTiet.ChucVu = BcbChucVu.SelectedItem.ToString();
            ChiTiet.DiaChi = BtxtDiaChi.Text.Trim();
            ChiTiet.DienThoai = BtxtDienThoai.Text.Trim();
            ChiTiet.DiDong = BtxtDiDong.Text.Trim();
            ChiTiet.Email = BtxtEmail.Text.Trim();
            try
            {
                 Data.NVChiTiet.Sua(ChiTiet);
            }
            catch (Exception)
            {
                MessageBox.Show("Mã vừa nhập vào không có.", "Loi du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            BLoadDuLieu();
        }

        private void BbtnXoa_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(BtxtMaChiTiet.Text.Trim()) == true)
            {
                return;
            }
            try
            {
                Data.NVChiTiet.Xoa(BtxtMaChiTiet.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("Mã vừa nhập vào không có.", "Loi du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            BLoadDuLieu();
        }

        void FixComBo(ComboBox ComBo, string Giatri)
        {
            for (int i = 0; i < ComBo.Items.Count; i++)
            {
                if ((ComBo.Items[i].ToString().Trim()==Giatri.Trim())||(string.Equals(ComBo.Items[i].ToString().Trim(),Giatri.Trim())))
                {
                    ComBo.SelectedIndex = i;
                    return;
                }
            }
        }

         private void BdgvDanhSach_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
            DataTable table = Connect.cnSQL.ExecQuery("Select * from ChiTiet where MaChiTiet='"+ BtxtMaChiTiet.Text.Trim() +"'");
            DataRow row = table.Rows[0];
            BtxtNguoiLienHe.Text = row["NguoiLienHe"].ToString();
            FixComBo(BcbChucVu,row["ChucVu"].ToString());
            BtxtDiaChi.Text = row["DiaChi"].ToString();
            BtxtDienThoai.Text = row["DienThoai"].ToString();
            BtxtDiDong.Text = row["DiDong"].ToString();
            BtxtEmail.Text = row["Email"].ToString();
            }
            catch (Exception)
            {

            }

        } 
        #endregion

        #region Phần mềm
         bool CKiemTraThongTinNhap()
        {
            if (string.IsNullOrEmpty(CtxtMaKhachHang.Text.ToString()) || (string.IsNullOrEmpty(CtxtTenPhanMem.Text.ToString())) || (string.IsNullOrEmpty(CtxtGhiChu.Text.ToString())))
            {
                MessageBox.Show("Bạn vui lòng kiểm tra lại thông tin nhập.","Loi nhap du lieu",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return false;
            }
            else
            {
                return true;
            }
        }
         void CDieuKhien()
         {
             CbtnSua.Enabled =CbtnXoa.Enabled = (CdgvDanhSach.RowCount != 0);
         }
         void CLoadComBo()
          {
             CtxtMaNhanVien.DataSource = Data.NVNhanVien.ChonTatCa();
             CtxtMaNhanVien .ValueMember = "MaNhanVien";
             CtxtMaNhanVien.DisplayMember = "TenNhanVien";
             if (CtxtMaNhanVien.Items.Count==0)
             {
                 CtxtMaNhanVien.Enabled = false;
             }
          }
         BindingSource Cbds = new BindingSource();
         void CLoadDuLieu()
         {
             CLoadComBo();
             Cbds.DataSource = Data.NVSoft.ChonTatCa(CtxtMaKhachHang.Text.Trim());
             CdgvDanhSach.DataSource = Cbds;
             CDieuKhien();

         }
         void CLoadComboNguoiLienhe()
         {
             CcbNguoiLienHe.DataSource = Data.NVChiTiet.ChonTatCa(CtxtMaKhachHang.Text.Trim());
             CcbNguoiLienHe.DisplayMember = "NguoiLienHe";
             CcbNguoiLienHe.ValueMember = "MaChiTiet";
             if (CcbNguoiLienHe.Items.Count==0)
             {
                 CcbNguoiLienHe.Enabled = false;
             }
         }

         private void CbtnThem_Click(object sender, EventArgs e)
         {
             CbtnThem.Enabled = false;
             if (CKiemTraThongTinNhap() == false)
             {
                 return;
             }
             Data.TTSoft Soft = new Data.TTSoft();
             Soft.Soft = SinhMa.Sinh("SW", Data.NVSoft.ChonTatCa(), "0000000000");
             Soft.MaKhachHang = CtxtMaKhachHang.Text.Trim();
             Soft.TenPhanMem = CtxtTenPhanMem.Text.Trim();
             Soft.ThoiGian = CtxtThoiGian.Value;
             if (string.IsNullOrEmpty(CtxtGhiChu.Text.Trim()) == false)
             {
                 if (CtxtGhiChu.Text.IndexOf(':') != -1)
                 {
                     Soft.GhiChu = CtxtGhiChu.Text;
                 }
                 else
                 {
                     Soft.GhiChu = "(" + CcbNguoiLienHe.Text.Trim() + ") : " + CtxtGhiChu.Text.Trim();
                 }

             }
             else
             {
                 Soft.GhiChu = "";
             }
             
             
             if (CchkKhongQuanLy.Checked == true) 
             {
                 Soft.MaNhanVien = "";
             }
             else
             {
                 Soft.MaNhanVien = CtxtMaNhanVien.SelectedValue.ToString();
             }
             Data.NVSoft.Them(Soft);
             CLoadDuLieu();
             CbtnThem.Enabled = true;
         }

         private void CbtnSua_Click(object sender, EventArgs e)
         {
             CbtnSua.Enabled = false;
             if (CKiemTraThongTinNhap() == false)
             {
                 return;
             }

             Data.TTSoft Soft = new Data.TTSoft();
             Soft.Soft = CtxtSoft.Text.Trim();
             Soft.MaKhachHang = CtxtMaKhachHang.Text.Trim();
             Soft.TenPhanMem = CtxtTenPhanMem.Text.Trim();
             Soft.ThoiGian = CtxtThoiGian.Value;
             if (string.IsNullOrEmpty(CtxtGhiChu.Text.Trim()) == false)
             {
                 if (CtxtGhiChu.Text.IndexOf(':') != -1)
                 {
                      Soft.GhiChu = CtxtGhiChu.Text;
                 }
                 else
                 {
                     Soft.GhiChu = "(" + CcbNguoiLienHe.Text.Trim() + ") : " + CtxtGhiChu.Text.Trim();
                 }
                
             }
             else
             {
                 Soft.GhiChu = "";
             }
             if (CchkKhongQuanLy.Checked == true)
             {
                 Soft.MaNhanVien = "";
             }
             else
             {
                 Soft.MaNhanVien = CtxtMaNhanVien.SelectedValue.ToString();
             }
             try
             {
                 Data.NVSoft.Sua(Soft);
             }
             catch (Exception)
             {
                 MessageBox.Show("Mã vừa nhập vào không có.", "Loi du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);

             }
             CLoadDuLieu();
             CbtnSua.Enabled = true;
         }

         private void CbtnXoa_Click(object sender, EventArgs e)
         {
             CbtnXoa.Enabled = false;
             if (CKiemTraThongTinNhap() == false)
             {
                 return;
             }
             try
             {

                 Data.NVSoft.Xoa(CtxtSoft.Text.Trim());
             }
             catch (Exception)
             {
                 MessageBox.Show("Mã vừa nhập vào không có.", "Loi du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);

             }
             CLoadDuLieu();
             CbtnXoa.Enabled = true;
         }
         private void CchkKhongQuanLy_CheckedChanged(object sender, EventArgs e)
         {
             CtxtMaNhanVien.Enabled = !CchkKhongQuanLy.Checked;
         }

         private void CdgvDanhSach_CellClick(object sender, DataGridViewCellEventArgs e)
         {
             if (string.IsNullOrEmpty(CtxtMaNhanVien.Text.Trim()))
             {
                 CchkKhongQuanLy.Checked = true;
             }
             else
             {
                 CchkKhongQuanLy.Checked = false;
             }
         }

         #endregion

         #region Website
         bool DKiemTraThongTinNhap()
         {
             if (string.IsNullOrEmpty(DtxtMaKhachHang.Text.ToString()) || (string.IsNullOrEmpty(DtxtTenWeb.Text.ToString())))
             {
                 MessageBox.Show("Bạn vui lòng kiểm tra lại thông tin nhập.", "Loi nhap du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return false;
             }
             else
             {
                 return true;
             }
         }
         void DDieuKhien()
         {
             DbtnSua.Enabled = DbtnXoa.Enabled = (DdgvDanhSach.RowCount != 0);
         }
         void DLoadComBo()
         {
             DtxtMaNhanVien.DataSource = Data.NVNhanVien.ChonTatCa();
             DtxtMaNhanVien.ValueMember = "MaNhanVien";
             DtxtMaNhanVien.DisplayMember = "TenNhanVien";
             if (DtxtMaNhanVien.Items.Count==0)
             {
                 DtxtMaNhanVien.Enabled = false;
             }
         }
         BindingSource Dbds = new BindingSource();
         void DLoadDuLieu()
         {
             DLoadComBo();
             Dbds.DataSource = Data.NVWeb.ChonTatCa(DtxtMaKhachHang.Text.Trim());
             DdgvDanhSach.DataSource = Dbds;
             DDieuKhien();
         }
         private void DbtnThem_Click(object sender, EventArgs e)
         {
             if (DKiemTraThongTinNhap() == false)
             {
                 return;
             }
             Data.TTWeb Web = new Data.TTWeb();
             Web.MaWeb = SinhMa.Sinh("WB", Data.NVWeb.ChonTatCa(), "0000000000");
             Web.MaKhachHang = DtxtMaKhachHang.Text.Trim();
             Web.TenWeb = DtxtTenWeb.Text.Trim();
             Web.DonViTK = DtxtDonViTK.Text.Trim();
             Web.ThoiGianTK = DtxtThoiGianTK.Value;
             Web.ThoiHanTM = DtxtThoiHanTM.Value;
             Web.MaNhanVien = DtxtMaNhanVien.SelectedValue.ToString();
             if (DchkToiKhongQuanLy.Checked == true)
             {
                 Web.MaNhanVien = "";
             }
             else
             {
                 Web.MaNhanVien = DtxtMaNhanVien.SelectedValue.ToString();
             }
             Data.NVWeb.Them(Web);
             DLoadDuLieu();
         }

         private void DbtnSua_Click(object sender, EventArgs e)
         {
             if (DKiemTraThongTinNhap() == false)
             {
                 return;
             }

             Data.TTWeb Web = new Data.TTWeb();
             Web.MaWeb = DtxtMaWeb.Text.Trim();
             Web.MaKhachHang = DtxtMaKhachHang.Text.Trim();
             Web.TenWeb = DtxtTenWeb.Text.Trim();
             Web.DonViTK = DtxtDonViTK.Text.Trim();
             Web.ThoiGianTK = DtxtThoiGianTK.Value;
             Web.ThoiHanTM = DtxtThoiHanTM.Value;
             Web.MaNhanVien = DtxtMaNhanVien.SelectedValue.ToString();
             if (DchkToiKhongQuanLy.Checked == true)
             {
                 Web.MaNhanVien = "";
             }
             else
             {
                 Web.MaNhanVien = DtxtMaNhanVien.SelectedValue.ToString();
             }
             try
             {
                 Data.NVWeb.Sua(Web);
             }
             catch (Exception)
             {
                 MessageBox.Show("Mã vừa nhập vào không có.", "Loi du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);

             }
             DLoadDuLieu();
         }

         private void DbtnXoa_Click(object sender, EventArgs e)
         {
             if (DKiemTraThongTinNhap() == false)
             {
                 return;
             }
             try
             {

                 Data.NVWeb.Xoa(DtxtMaWeb.Text.Trim());
             }
             catch (Exception)
             {
                 MessageBox.Show("Mã vừa nhập vào không có.", "Loi du lieu", MessageBoxButtons.OK, MessageBoxIcon.Error);

             }
             DLoadDuLieu();
         }

         private void DchkToiKhongQuanLy_CheckedChanged(object sender, EventArgs e)
         {
             DtxtMaNhanVien.Enabled = !DchkToiKhongQuanLy.Checked;
         }

         private void DdgvDanhSach_CellClick(object sender, DataGridViewCellEventArgs e)
         {
             if (string.IsNullOrEmpty(DtxtMaNhanVien.Text.Trim()))
             {
                 DchkToiKhongQuanLy.Checked = true;
             }
             else
             {
                 DchkToiKhongQuanLy.Checked = false;
             }
             if (DdgvDanhSach.RowCount>0)
             {
                 ELoadDuLieu();
                 EtxtCode.DataBindings.Clear();
                 EtxtCode.DataBindings.Add("Text", Ebds, "Code", true, DataSourceUpdateMode.Never);
                 EtxtGhiChu.DataBindings.Clear();
                 EtxtGhiChu.DataBindings.Add("Text", Ebds, "GhiChu", true, DataSourceUpdateMode.Never);
                 EtxtThoiGian.DataBindings.Clear();
                 EtxtThoiGian.DataBindings.Add("Value", Ebds, "ThoiGian", true, DataSourceUpdateMode.Never);
             }

         }



         #endregion

         #region Ghi chú website
         void ELoadComboNguoiLienHe()
         {
             EcbNguoiLienHe.DataSource = Data.NVChiTiet.ChonTatCa(DtxtMaKhachHang.Text.Trim());
             EcbNguoiLienHe.DisplayMember = "NguoiLienHe";
             EcbNguoiLienHe.ValueMember = "MaChiTiet";
             if (EcbNguoiLienHe.Items.Count == 0)
             {
                 EcbNguoiLienHe.Enabled = false;
             }
         }
         BindingSource Ebds = new BindingSource();
         void ELoadDuLieu()
         {
             ELoadComboNguoiLienHe();
             Ebds.DataSource = Data.NVWGhiChu.ChonTatCa(DtxtMaWeb.Text.Trim());
             EdgvDanhSach.DataSource = Ebds;
             EDieuKhien();
         }
         void EDieuKhien()
         {
            EbtnXoa.Enabled = (EdgvDanhSach.RowCount != 0);
         }

         #endregion

         private void fThongTin_Load(object sender, EventArgs e)
        {
            LoadThongTinChung();

            #region Thôn tin  liên hệ
            BLoadDuLieu();
            BtxtMaChiTiet.DataBindings.Clear();
            BtxtMaChiTiet.DataBindings.Add("Text", Bbds, "MaChiTiet", true, DataSourceUpdateMode.Never);
            BtxtNguoiLienHe.DataBindings.Clear();
            BtxtNguoiLienHe.DataBindings.Add("Text", Bbds, "NguoiLienHe", true, DataSourceUpdateMode.Never);
            BcbChucVu.DataBindings.Clear();
            BcbChucVu.DataBindings.Add("SelectedItem", Bbds, "ChucVu", true, DataSourceUpdateMode.Never);
            BtxtDiaChi.DataBindings.Clear();
            BtxtDiaChi.DataBindings.Add("Text", Bbds, "DiaChi", true, DataSourceUpdateMode.Never);
            BtxtDienThoai.DataBindings.Clear();
            BtxtDienThoai.DataBindings.Add("Text", Bbds, "DienThoai", true, DataSourceUpdateMode.Never);
            BtxtDiDong.DataBindings.Clear();
            BtxtDiDong.DataBindings.Add("Text", Bbds, "DiDong", true, DataSourceUpdateMode.Never);
            BtxtEmail.DataBindings.Clear();
            BtxtEmail.DataBindings.Add("Text", Bbds, "Email", true, DataSourceUpdateMode.Never);           
            #endregion      

            #region Phần mềm
            CLoadDuLieu();
            CtxtSoft.DataBindings.Clear();
            CtxtSoft.DataBindings.Add("Text", Cbds, "Soft", true, DataSourceUpdateMode.Never);
            CtxtTenPhanMem.DataBindings.Clear();
            CtxtTenPhanMem.DataBindings.Add("Text", Cbds, "TenPhanMem", true, DataSourceUpdateMode.Never);
            CtxtThoiGian.DataBindings.Clear();
            CtxtThoiGian.DataBindings.Add("Text", Cbds, "ThoiGian", true, DataSourceUpdateMode.Never);
            CtxtGhiChu.DataBindings.Clear();
            CtxtGhiChu.DataBindings.Add("Text", Cbds, "GhiChu", true, DataSourceUpdateMode.Never);
            CtxtMaNhanVien.DataBindings.Clear();
            CtxtMaNhanVien.DataBindings.Add("SelectedValue", Cbds, "MaNhanVien", true, DataSourceUpdateMode.Never);
       
            #endregion

            #region Website
            DLoadDuLieu();
            DtxtMaWeb.DataBindings.Clear();
            DtxtMaWeb.DataBindings.Add("Text", Dbds, "MaWeb", true, DataSourceUpdateMode.Never);
            DtxtTenWeb.DataBindings.Clear();
            DtxtTenWeb.DataBindings.Add("Text", Dbds, "TenWeb", true, DataSourceUpdateMode.Never);
            DtxtDonViTK.DataBindings.Clear();
            DtxtDonViTK.DataBindings.Add("Text", Dbds, "DonViTK", true, DataSourceUpdateMode.Never);
            DtxtThoiGianTK.DataBindings.Clear();
            DtxtThoiGianTK.DataBindings.Add("Value", Dbds, "ThoiGianTK", true, DataSourceUpdateMode.Never);
            DtxtThoiHanTM.DataBindings.Clear();
            DtxtThoiHanTM.DataBindings.Add("Value", Dbds, "ThoiHanTM", true, DataSourceUpdateMode.Never);
            DtxtMaNhanVien.DataBindings.Clear();
            DtxtMaNhanVien.DataBindings.Add("SelectedValue", Dbds, "MaNhanVien", true, DataSourceUpdateMode.Never);
            #endregion


        }



         private void MainTab_SelectedIndexChanged(object sender, EventArgs e)
         {   if (MainTab.SelectedIndex==1)
             {
                 BcbChucVu.SelectedIndex = 0;
             }
             if (MainTab.SelectedIndex==2)
             { 
                 CLoadComBo();
                 CLoadComboNguoiLienhe();
             }
             if (MainTab.SelectedIndex==3)
             {
                 DLoadComBo();
                 ELoadComboNguoiLienHe();
             }
         }
        // Có đoạn lệnh load DataBinding trên D
         //private void DdgvDanhSach_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
         //{
         //    ELoadDuLieu();
         //}



         private void EbtnThem_Click(object sender, EventArgs e)
         {
             EbtnThem.Enabled = false;
            if ((string.IsNullOrEmpty(EtxtGhiChu.Text.Trim()))||(string.IsNullOrEmpty(DtxtMaWeb.Text.Trim())))
            {
                MessageBox.Show("Bạn chưa chọn Websit ở bảng trên để ghi chú ","Loi" );
       EbtnThem.Enabled = true;
                return;
            }
            Data.TTWGhiChu WGhiChu = new Data.TTWGhiChu();
            WGhiChu.Code = SinhMa.Sinh("WG", Data.NVWGhiChu.ChonTatCa(), "000000000000");
            WGhiChu.ThoiGian = EtxtThoiGian.Value;
            WGhiChu.GhiChu = EtxtGhiChu.Text.Trim();
            WGhiChu.MaWeb = DtxtMaWeb.Text.Trim();
            try
            {
                Data.NVWGhiChu.Them(WGhiChu);
                Estatus.Text = "Thêm thông tin ghi chú cho ngày " + EtxtThoiGian.Value + " thành công";
                ELoadDuLieu();
            }
            catch (Exception ex)
            {
                Estatus.Text = ex.Message; 
            }
            EbtnThem.Enabled = true;
         }

         private void EbtnXoa_Click(object sender, EventArgs e)
         {
             EbtnXoa.Enabled = false;
           if ((string.IsNullOrEmpty(EtxtGhiChu.Text.Trim()))||(string.IsNullOrEmpty(DtxtMaWeb.Text.Trim()))||(string.IsNullOrEmpty(EtxtCode.Text.Trim())))
            {
                MessageBox.Show("Bạn chưa chọn Website ở bảng trên để ghi chú ","Loi" );
            EbtnXoa.Enabled = true;
                return;
            }

            try
            {
                Data.NVWGhiChu.Xoa(EtxtCode.Text.Trim());
                Estatus.Text = "Xóa thông tin ngày " + EtxtThoiGian.Value + " thành công";
                ELoadDuLieu();
            }
            catch (Exception ex)
            {
                Estatus.Text = ex.Message; 
            }
            EbtnXoa.Enabled = true;
         }



   


            
            






   
    }
}
